<template>
	<view class="login">
		<view class="container">
			<view class="wrapper">
				<view class="welcome">
					<image src="@/static/logo.png" mode=""></image>
					<!-- <view class="labelname">
						欧弗CRM
					</view> -->
				</view>
				<view class="input-content">
					<view class="input-item">
						<cl-input v-model="username" placeholder="请输入账号">
							<image slot="prepend" src="@/static/pageImg/phone.png"></image>
						</cl-input>
					</view>
					<view class="input-item">
						<cl-input v-model="password" type="password" placeholder="请输入密码">
							<image slot="prepend" src="@/static/pageImg/password.png"></image>
						</cl-input>
					</view>
					<button class="confirm-btn" :class="'bg-' + themeColor.name" @tap="login">
						登录
					</button>
					<view @tap="updatePwd">
						忘记密码?
					</view>	
				</view>
			</view>
		</view>
	</view>
	</view>
</template>
<script>
	import store from '@/store';
	import api from "@/api/api"
	export default {
		components: {

		},
		data() {
			return {
				username: '',
				password: '',
				mobile: '',
				captcha: '',
				loginType: 'password',
				smsTimer: null,
				state: {
					time: 60,
					smsSendBtn: false,
				},
			};
		},
		onShow() {
			this.initData()
		},
		methods: {
			updatePwd(){
				uni.navigateTo({
					url: '/pages/public/password'
				});
			},
			// 数据初始化
			initData() {
				uni.setNavigationBarColor({
					frontColor: '#000000',
					backgroundColor: '#ffffff',
					animation: {
						duration: 400,
						timingFunc: 'easeIn'
					}
				})
			},
			// 返回上一页
			navBack() {
				this.$mRouter.back();
			},
			// 统一跳转路由
			navTo(route) {
				this.$mRouter.push({
					route
				});
			},
			// 返回主页
			toHome(route) {
				uni.switchTab({
					url: route
				});
			},
			login() {
				let that = this;
				if (!this.username) {
					this.$mHelper.toast('请输入用户名')
					return false;
				}
				if (!this.password) {
					this.$mHelper.toast('请输入密码')
					return false;
				}
				this.$http.post(api.getCodeLogin, {
					username: this.username,
					aesPassword: this.password,
					isCheckKey: 'N'
				}).then((res) => {
					if (res.code == "0") {
						store.commit('login', res.result);
						uni.reLaunch({
							url: "../tabbar/firstpage/firstpage"
						})
					} else {
						this.$mHelper.toast(res.message)
					}
				});

			}




		}
	}
</script>
<style lang="scss">

	.login {
		height: 100vh;
		background-color: #fff;
	}

	.container {
		padding-top: 40%;
		position: relative;
		width: 100vw;
		overflow: hidden;
		background: #fff;

		.wrapper {
			position: relative;
			z-index: 90;
			background: #fff;
			padding-bottom: 40upx;

			.captchainput {
				width: calc(100% - 120px);
			}

			.smscodebtn {
				width: 113px;
				position: absolute;
				right: 40px;
			}

			.bottomtip {
				color: #999;
				padding: 36rpx 60rpx;
			}
		}

		.welcome {
			position: relative;
			font-size: 46upx;
			color: #555;
			text-shadow: 1px 0px 1px rgba(0, 0, 0, 0.3);
			margin-bottom: 15px;

			.labelname {
				text-align: center;
				font-size: 18px;
				font-weight: 600;
			}

			image {
				width: 125px;
				height: 125px;
				left: 50%;
				transform: translateX(-50%);
			}
		}

		.input-content {
			padding: 0 60upx;
		}

		.input-item {
			margin-bottom: 50rpx;

			/deep/.cl-input {
				height: 90rpx;
			}

			.captchabtn {
				width: 200rpx;
				height: 64rpx;
				line-height: 64rpx;
				font-size: 28rpx;
				border-radius: 10rpx;
				color: #3f9eff;
				background-color: #fff;
				border: 1rpx solid #3f9eff;
			}


			/deep/.cl-input__append {
				margin-right: 10rpx;
			}


			image {
				width: 48rpx;
				height: 48rpx;
			}
		}
	}
</style>
